<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script type="text/javascript" src="../js/vue.js"></script>
    <script type="text/javascript" src="../js/axios.min.js"></script>
    <script type="text/javascript" src="../js/jquery.min.js"></script>
    <script type="text/javascript" src="../js/bootstrap.min.js"></script>
    <link rel="stylesheet" type="text/css" href="../css/bootstrap.min.css">
</head>

<body>
    <div class="container">
        <div id="app">
            <base-input v-model="username" label='姓名' required placeholder="enter your username"></base-input>
        </div>
        <script>
            Vue.component('base-input', {
                inheritAttrs: false,
                props: ['label', 'value'],
                template: `<label>{{label}}<input v-bind='$attrs' :value='value' @input='$emit("input", $event.target.value)'></label>`,
                mounted: function() {
                    console.log(this.$attrs);
                },
            });

            var vm = new Vue({
                el: '#app',
                data: {
                    username: 'hekun'
                },
                methods: {}
            });
        </script>
        <hr>
        <div id="app2">
            <base-checkbox v-model="lovingVue"></base-checkbox>
        </div>
        <script>
            Vue.component('base-checkbox', {
                props: {
                    checked: Boolean
                },
                model: {
                    prop: 'checked',
                    event: 'changes'
                },
                template: `<input type='checkbox' :checked='checked' @change='$emit("changes", $event.target.checked)'>`
            });

            var app2 = new Vue({
                el: '#app2',
                data: {
                    lovingVue: true
                },
                methods: {}
            });
        </script>
    </div>
</body>

</html>